using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace ERPBackend.Models
{
    public class SalesContractItem : BaseModel
    {
        /// <summary>
        /// 销售合同ID
        /// </summary>
        [Required]
        public int SalesContractId { get; set; }

        /// <summary>
        /// 销售合同
        /// </summary>
        [ForeignKey("SalesContractId")]
        public SalesContract SalesContract { get; set; }

        /// <summary>
        /// 物料ID
        /// </summary>
        [Required]
        public int MaterialId { get; set; }

        /// <summary>
        /// 物料
        /// </summary>
        [ForeignKey("MaterialId")]
        public Material Material { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        [Required]
        [MaxLength(255)]
        public string MaterialName { get; set; }

        /// <summary>
        /// 规格型号
        /// </summary>
        [MaxLength(255)]
        public string Specification { get; set; }

        /// <summary>
        /// 计量单位
        /// </summary>
        [MaxLength(50)]
        public string Unit { get; set; }

        /// <summary>
        /// 合同数量
        /// </summary>
        [Required]
        [Column(TypeName = "decimal(18,4)")]
        public decimal Quantity { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        [Required]
        [Column(TypeName = "decimal(18,4)")]
        public decimal UnitPrice { get; set; }

        /// <summary>
        /// 金额（数量×单价）
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal Amount { get; set; }

        /// <summary>
        /// 税率
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal TaxRate { get; set; }

        /// <summary>
        /// 税额
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal TaxAmount { get; set; }

        /// <summary>
        /// 价税合计金额
        /// </summary>
        [Column(TypeName = "decimal(18,4)")]
        public decimal TotalAmount { get; set; }

        /// <summary>
        /// 交付日期
        /// </summary>
        public DateTime? DeliveryDate { get; set; }

        /// <summary>
        /// 行号
        /// </summary>
        public int LineNumber { get; set; }
    }
}